using UnityEngine;
using System.Collections;

public class MeleeWeapon : Weapon
{
    #region Attributes

    private bool isDamageOn = false;

    #endregion

    #region Weapon Methods

    public override void AttackStart()
    {
        this.isDamageOn = true;
    }

    public override void AttackEnd()
    {
        this.isDamageOn = false;
    }

    #endregion

    #region Unity Methods

    void OnTriggerStay(Collider other)
    {
        if (this.isDamageOn && other.name.Contains(Constants.PLAYER_NAME))
        {
            Debug.Log("TE PEGE: Other.TakeDamage()");
            PlayerControl pc = other.gameObject.GetComponent<PlayerControl>();
            //EnemyControl ec = other.gameObject.GetComponent<EnemyControl>();
            if (pc != null)
                pc.TakeDamage(this.damage);
            this.AttackEnd();
        }
    }

    #endregion
}
